//
//  MinorTableViewCell.m
//  StockNetManager
//
//  Created by 小焘无量 on 2023/4/2.
//

#import "MinorTableViewCell.h"

@interface MinorTableViewCell()

@property (weak, nonatomic) IBOutlet UILabel *phoneLab;
@property (weak, nonatomic) IBOutlet UILabel *companyNameLab;
@property (weak, nonatomic) IBOutlet UILabel *registerTimeLab;
@property (weak, nonatomic) IBOutlet UILabel *memberTimeLab;
@property (weak, nonatomic) IBOutlet UILabel *countLab;

@end

@implementation MinorTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)setModel:(MinorListModel *)model {
    _model = model;
    
    self.phoneLab.text = FormatString(@"%@", model.phone);
    if (![model.company.name isNotBlank]) {
        self.companyNameLab.hidden = YES;
    } else {
        self.companyNameLab.hidden = NO;
        self.companyNameLab.text = FormatString(@"%@", model.company.name);
    }
    
    self.registerTimeLab.text = [model.createTime componentsSeparatedByString:@" "].firstObject;
    

    NSString *memberEndTime = [model.expirationTime componentsSeparatedByString:@" "].firstObject;
    memberEndTime = [memberEndTime stringByReplacingOccurrencesOfString:@"-" withString:@"/"];
    
    if (![model.openingTime isNotBlank]) {
        self.memberTimeLab.text = FormatString(@"会员截止：%@", memberEndTime);
    } else {
        NSString *memberStartTime = [model.openingTime componentsSeparatedByString:@" "].firstObject;
        memberStartTime = [memberStartTime stringByReplacingOccurrencesOfString:@"-" withString:@"/"];
        
        self.memberTimeLab.text = FormatString(@"会员日期：%@ - %@", memberStartTime, memberEndTime);
    }
    
    if (model.checkType == CheckType_Member) {
        self.countLab.hidden = YES;
    } else if (model.checkType == CheckType_Report){
        self.countLab.hidden = NO;
        self.countLab.text = FormatString(@"被投诉次数:%@", model.complainedNum);
    } else if (model.checkType == CheckType_Price){
        self.countLab.hidden = NO;
        self.countLab.text = FormatString(@"询价次数:%@", model.inquiriesNum);
    } else if (model.checkType == CheckType_Stock){
        self.countLab.hidden = NO;
        self.countLab.text = FormatString(@"上传库存次数:%@", model.uploadStockNum);
    }
    
}

@end
